package org.example.backend.demos.web.api;

import org.example.backend.demos.web.NewsModule.entity.News;
import org.example.backend.demos.web.result.Pages;
import org.example.backend.demos.web.result.Result;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
public interface newsApi {


    @RequestMapping(path = "api/search", method = RequestMethod.GET)
    @ResponseBody
    ResponseEntity<Result> queryByPage_limit(News news, PageRequest pageRequest);

    //获取所有新闻 例子 http://localhost:8080/news/api/allproject
    @RequestMapping(path = "api/allnews", method = RequestMethod.GET)
    @ResponseBody
    ResponseEntity<Result> Allnews();


    // 获取项目分页列表 例子 http://localhost:8080/news/api/page?page=1&size=5
    @RequestMapping(path = "api/page", method = RequestMethod.GET)
    @ResponseBody
    ResponseEntity<Result> queryByPage(int page, int size);


    // 获取项目分页列表 例子 http://localhost:8080/news/api/page_Pages?offset=1&pageSize=5
    @RequestMapping(path = "api/page_Pages", method = RequestMethod.GET)
    @ResponseBody
    ResponseEntity<Result> queryByPage_Pages(Pages pages);

    //获取新闻详情 例子 http://localhost:8080/news/api/1
    //检测 python sqlmap.py -u "http://localhost:8080/news?id=1"
    @RequestMapping(path = "api/{id}", method = RequestMethod.GET)
    @ResponseBody
    ResponseEntity<Result> queryById(@PathVariable("id") Long id);

    //新增新闻(需管理员权限)
    @RequestMapping(path = "api/add", method = RequestMethod.POST)
    @ResponseBody
    ResponseEntity<Result> add(News news);

    //更新新闻(需管理员权限)
    @RequestMapping(path = "api/update", method = RequestMethod.PUT)
    @ResponseBody
    ResponseEntity<Result> edit(News news);

    //删除新闻(需管理员权限)
    @RequestMapping(path = "api/delete", method = RequestMethod.DELETE)
    @ResponseBody
    ResponseEntity<Result> deleteById(Long id);
}
